﻿Imports DTO
Imports BUS

Public Class MH_TimKiemHocSinhNangCao
    Public dataTimKiem As DataTable
    Private hsCRT As New HocSinhCRT



    Private Sub chkGioiTinh_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkGioiTinh.CheckedChanged

        If chkGioiTinh.Checked = True Then
            cboGioiTinh.Enabled = True
        Else
            cboGioiTinh.Enabled = False
        End If

    End Sub

    Private Sub chkNgaySinh_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkNgaySinh.CheckedChanged
        If chkNgaySinh.Checked = True Then
            dtpNgaySinhDen.Enabled = True
            dtpNgaySinhTu.Enabled = True
        Else
            dtpNgaySinhDen.Enabled = False
            dtpNgaySinhTu.Enabled = False
        End If
    End Sub

    Private Sub chkDiaChi_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkDiaChi.CheckedChanged
        If chkDiaChi.Checked = True Then
            txtDiaChi.Enabled = True
        Else
            txtDiaChi.Enabled = False
        End If
    End Sub

    Private Sub chkLopHoc_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkLopHoc.CheckedChanged
        If chkLopHoc.Checked = True Then
            cboLopHoc.Enabled = True
        Else
            cboLopHoc.Enabled = False
        End If
    End Sub

    Private Sub chkMonHoc_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkMonHoc.CheckedChanged
        If chkMonHoc.Checked = True Then
            cboMonHoc.Enabled = True
            GroupBox3.Enabled = True
        Else
            cboMonHoc.Enabled = False
            GroupBox3.Enabled = False
        End If
    End Sub

    Private Sub chkDiem15P_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkDiem15P.CheckedChanged
        If chkDiem15P.Checked = True Then
            nudDiem15PTu.Enabled = True
            nudDiem15PDen.Enabled = True
        Else
            nudDiem15PTu.Enabled = False
            nudDiem15PDen.Enabled = False
        End If
    End Sub

    Private Sub chkDiem1T_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkDiem1T.CheckedChanged
        If chkDiem1T.Checked = True Then
            nudDiem1TTu.Enabled = True
            nudDiem1TDen.Enabled = True
        Else
            nudDiem1TTu.Enabled = False
            nudDiem1TDen.Enabled = False
        End If
    End Sub

    Private Sub chkDiemHK_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkDiemHK.CheckedChanged
        If chkDiemHK.Checked = True Then
            nudDiemHKTu.Enabled = True
            nudDiemHKDen.Enabled = True
        Else
            nudDiemHKTu.Enabled = False
            nudDiemHKDen.Enabled = False
        End If
    End Sub





    Private Sub CapNhatTieuChuanTraCuu(ByVal bUpdated As Boolean)
        If (bUpdated) Then
            hsCRT.TenHS = txtTenHocSinh.Text.Trim()
            hsCRT.GioiTinh = cboGioiTinh.Text
            hsCRT.NgaySinhTu = dtpNgaySinhTu.Value.Date
            hsCRT.NgaySinhDen = dtpNgaySinhDen.Value.Date
            hsCRT.DiaChi = txtDiaChi.Text.Trim()
            hsCRT.MaLop = cboLopHoc.SelectedValue
            hsCRT.MaMon = cboMonHoc.SelectedValue
            hsCRT.Diem15PhutTu = nudDiem15PTu.Value
            hsCRT.Diem15PhutDen = nudDiem15PDen.Value
            hsCRT.Diem1TietTu = nudDiem1TTu.Value
            hsCRT.Diem1TietDen = nudDiem1TDen.Value
            hsCRT.DiemKHTu = nudDiemHKTu.Value
            hsCRT.DiemKHDen = nudDiemHKDen.Value

            hsCRT.CheckGioiTinh = chkGioiTinh.Checked
            hsCRT.CheckNgaySinh = chkNgaySinh.Checked
            hsCRT.CheckDiaChi = chkDiaChi.Checked
            hsCRT.CheckLop = chkLopHoc.Checked
            hsCRT.CheckMon = chkMonHoc.Checked
            hsCRT.CheckDiem15Phut = chkDiem15P.Checked
            hsCRT.CheckDiem1Tiet = chkDiem1T.Checked
            hsCRT.CheckDiemHK = chkDiemHK.Checked

        Else
            'If (hsCRT.Ma <> 0) Then
            '    txtMaHocSinh.Text = hsCRT.Ma.ToString()
            'End If
            'txtTenHocSinh.Text = hsCRT.Ten
            'dtpNgaySinhTu.Value = hsCRT.NgaySinhTu.Date
            'dtpNgaySinhDen.Value = hsCRT.NgaySinhDen.Date
            'txtDiaChi.Text = hsCRT.DiaChi
            'nudDiemToanTu.Value = hsCRT.ToanTu
            'nudDiemToanDen.Value = hsCRT.ToanDen
            'nudDiemLyTu.Value = hsCRT.LyTu
            'nudDiemLyDen.Value = hsCRT.LyDen
            'nudDiemHoaTu.Value = hsCRT.HoaTu
            'nudDiemHoaDen.Value = hsCRT.HoaDen
            'nudDTBTu.Value = hsCRT.DTBTu
            'nudDTBDen.Value = hsCRT.DTBDen
            'chkNgaySinh.Checked = hsCRT.CheckNgaySinh
            'chkDiaChi.Checked = hsCRT.CheckDiaChi
            'chkDiemToan.Checked = hsCRT.CheckToan
            'chkDiemLy.Checked = hsCRT.CheckLy
            'chkDiemHoa.Checked = hsCRT.CheckHoa
            'chkDTB.Checked = hsCRT.CheckDTB
            'chkLopHoc.Checked = hsCRT.CheckLopHoc
        End If
    End Sub





    Private Sub btnTraCuu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTraCuu.Click
        Try
            dataTimKiem.Clear()
        Catch ex As Exception

        End Try
        Try
            CapNhatTieuChuanTraCuu(True)
            Dim hsBUS As New HocSinhBUS()
            Dim dtHocSinh As DataTable
            dtHocSinh = hsBUS.TimKiemNangCao(hsCRT)
            dgvDanhSach.DataSource = dtHocSinh
            dgvDanhSach.Columns("MAHOCSINH").Visible = False
            dataTimKiem = dtHocSinh
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

    End Sub

    Private Sub MH_TimKiemHocSinhNangCao_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Load danh sách lớp
        Dim lopBUS As New LopBUS
        cboLopHoc.DataSource = lopBUS.LayDanhSach()
        cboLopHoc.DisplayMember = ("TenLop")
        cboLopHoc.ValueMember = ("MaLop")
        'Load danh sách môn học
        Dim mhBUS As New MonHocBUS
        cboMonHoc.DataSource = mhBUS.LayDanhSach()
        cboMonHoc.DisplayMember = ("TenMon")
        cboMonHoc.ValueMember = ("MaMon")
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub
End Class